// hdu4609
// 题意：
// 有n(<=10^5)条线段，每条线段ai(<=10^5)，随机取三个组成三角形的概率。
//
// 题解：
// 设一个多项式 f(x)=sigma(x^ai)，这个多项式的卷积就是两个线段的和，
// 然后我们枚举最长边，算一下答案，再减去不合法的方案，比如我们枚举的
// 最长边是i，卷积中自己乘自己的是不合法的，比i大乘以比i小的或者两个
// 都是比i大的都是不合法的。
//
// run: time -p $exec < bfdiff.in
#include <iostream>
#include <iomanip>
#include <complex>
#include <algorithm>
#include <vector>
#include <cmath>

int const maxn = 100007;

namespace fft
{
	using base = std::complex<double>;
	double const pi = std::acos(-1);

	int rev[4 * maxn];
	base wlen_pw[4 * maxn];

	void fft(base a[], int n, bool invert)
	{
		for (int i = 0; i < n; i++)
			if (i < rev[i]) std::swap(a[i], a[rev[i]]);

		for (int len = 2; len <= n; len *= 2) {
			double ang = (2 * pi / len) * (invert ? -1 : 1);
			int len2 = len / 2;
			base wlen(std::cos(ang), std::sin(ang));
			wlen_pw[0] = base(1, 0);
			for (int i = 1; i < len2; i++)
				wlen_pw[i] = wlen_pw[i - 1] * wlen;

			for (int i = 0; i < n; i += len) {
				base t, *pu = a + i, *pv = a + i + len2, *pu_end = a + i + len2, *pw = wlen_pw;
				for (; pu != pu_end; ++pu, ++pv, ++pw) {
					t = *pv * *pw;
					*pv = *pu - t;
					*pu += t;
				}
			}
		}

		if (!invert) return;
		for (int i = 0; i < n; i++) a[i] /= n;
	}

	void calc_rev(int n)
	{
		int logn = 0;
		while ((1 << logn) < n) logn++;
		for (int i = 0; i < n; i++) {
			rev[i] = 0;
			for (int j = 0; j < logn; j++)
				if (i & (1 << j))
					rev[i] |= 1 << (logn - j - 1);
		}
	}

	base fa[4 * maxn];

	template <class T>
	void self_multiply(std::vector<int> const& a, int n1, std::vector<T> & res, int & len)
	{
		int n = 1;
		while (n < n1) n *= 2;
		n *= 2; len = n;
		for (int i = 0; i < n1; i++) fa[i] = a[i];
		for (int i = n1; i < n; i++) fa[i] = 0;

		calc_rev(n);
		fft(fa, n, false);
		for (int i = 0; i < n; i++) fa[i] *= fa[i];
		fft(fa, n, true);

		for (int i = 0; i < n; i++) res[i] = std::round(fa[i].real());

		// normalized
		/*
		int carry = 0;
		for (int i = 0; i < n; i++) { res[i] += carry; carry = res[i] / 10; res[i] %= 10; }
		*/
	}
}

long long sum[maxn * 4];
int b[maxn];
std::vector<int> a(maxn);
std::vector<long long> res(4 * maxn);
long long n;

int main()
{
	std::ios_base::sync_with_stdio(false);
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n;
		std::fill(a.begin(), a.end(), 0);
		int max = 0;
		for (int i = 0; i < n; i++) {
			std::cin >> b[i];
			max = std::max(max, b[i]);
			a[b[i]]++;
		}
		max++;
		int len;
		fft::self_multiply(a, max, res, len);
		for (int i = 0; i < n; i++)
			res[b[i] * 2]--;
		for (int i = 0; i < len; i++) res[i] /= 2;

		sum[len] = 0;
		for (int i = len - 1; i >= 0; i--)
			sum[i] = sum[i + 1] + res[i];

		std::sort(b, b + n);
		double ans = 0;
		for (int i = 0; i < n; i++) {
			ans += sum[b[i] + 1];
			long long large = n - i - 1;
			long long small = i;
			ans -= large * small + large * (large - 1) / 2;
			ans -= n - 1;
		}
		ans /= n * (n - 1) * (n - 2) / 6;
		std::cout << std::fixed << std::setprecision(7) << ans << "\n";
	}
}

